<template>
	<view>
		<view style="height: 30rpx;"></view>
		
		<view class="cardBox" style="margin-top: 0rpx;">
			<view class="flex" style="margin-top: 10rpx;">
				<view class="biao">
					<span class="biao_span">|</span> 
					<text style="font-size: 32rpx;">{{text.apply}}  </text> 
				</view>
			</view>
			<view  style="margin-top: 10rpx;padding-bottom: 20rpx;">
				<view>{{$t("口岸交接人名称")}}</view>
				<u-form-item >
					<u-input v-model="consignee"  :custom-style="{height:'50rpx'}" height="50"  type="text"  :placeholder="$t('请输入口岸交接人名称')"/>
				</u-form-item>
			</view>
			<view  style="margin-top: 10rpx;padding-bottom: 20rpx;">
				<view>{{$t("联系方式")}}</view>
				<u-form-item >
					<u-input v-model="consignee_tel"  :custom-style="{height:'50rpx'}" height="50"  type="number" :placeholder="$t('请输入联系方式')"/>
				</u-form-item>
			</view>
		</view>
		
		<view style="display: flex;width:90%;margin-left:5%">
			<view style="width: 100%;">
				<u-button v-if="xg==0" @click="subForm()"  style="" :custom-style="customStyle2" hover-class="none" :disabled="subDisabled" type="primary"
					>
					{{ $t('确认添加') }}
				</u-button>
				<u-button v-else @click="subForm()"  style="" :custom-style="customStyle2" hover-class="none" :disabled="subDisabled" type="primary"
					>
					{{ $t('确认修改') }}
				</u-button>
			</view>
		</view>
		<view style="height: 30px;"></view>	
		
	</view>
</template>

<script>
	import {HTTP_REQUEST_URL,HTTP_IMG_UTL,IMAGE_URL} from "@/config/app";
	import formImages from "@/components/buildForm/formImages.vue";
	
	export default {
		components: {
			formImages
		},
		data() {
			return {
				//远程域名
				HTTP_IMG_UTL,
				HTTP_REQUEST_URL,
				IMAGE_URL,
				url: IMAGE_URL,
				
				//语言
				lang: this.$i18n.locale,
				//文字
				text:{
					apply:this.$t('口岸交接人信息'),
				},
				subDisabled:false,
				loading:false,
				customStyle2: {
					width: '500rpx',
					height: '83rpx',
					marginTop:'20rpx',
					fontSize:'24rpx',
					background: '#ff2323',
					borderRadius: '56rpx'
				},
				consignee_tel:'',
				consignee:'',
				id:'',
				join_order_id:'',
				status:'',
				xg:0,
			}
		},
		onLoad(options) {
			if(options.id){
				this.id=options.id
				this.join_order_id=options.join_order_id
				this.status=options.status
			}
			if(options.xg){
				this.xg=options.xg
			}
			this.$u.api.order.consigneeInfo({
				id:this.id,
			}).then(res => {
				this.consignee=res.kaconsignee
				this.consignee_tel=res.kaconsignee_tel
			})
		},
		onReady() {
			if(this.xg==1){
				var title_ = "修改口岸交接人";
				if(this.lang=='ru'){
					title_ = "Редактирование данных";
				}
				uni.setNavigationBarTitle({		//自定义标题
					title: title_
				})
			}else{
				var title_ = "添加口岸交接人";
				if(this.lang=='ru'){
					title_ = "Добавить получателя";
				}
				uni.setNavigationBarTitle({		//自定义标题
					title: title_
				})
			}
		},
		methods:{
			subForm(){
				const that = this
				if((that.consignee=='')||(that.consignee==null)){
					uni.showModal({
						content: that.$t('请输入口岸交接人名称'),
						showCancel: false,
						confirmText: this.$t('是'),
					})
					return false;
				}
				if((that.consignee_tel=='')||(that.consignee_tel==null)){
					uni.showModal({
						content: that.$t('请输入联系方式'),
						showCancel: false,
						confirmText: this.$t('是'),
					})
					return false;
				}
				uni.showLoading({
					title: "Loading...",
					mask: true
				})
				that.$u.api.order.saveKaConsignee({
					id:that.id,
					lang:that.lang,
					kaconsignee:that.consignee,
					kaconsignee_tel:that.consignee_tel,
				}).then(res => {
					uni.hideLoading();
					
					uni.showModal({
						content: that.$t('操作成功'),
						showCancel: false,
						confirmText: this.$t('是'),
					})
					setTimeout(function() {
						uni.redirectTo({
							url: '/pages/ordering/orderDetail?id='+that.id+'&join_order_id='+that.join_order_id+'&status='+that.status+'&isDetail=true'
						  });
					}, 2000);
					
					return false;
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	@import "uview-ui/index.scss";
	@import "@/common/orderDetail.scss";
</style>